<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <div>1</div>
  <div>2</div>
  <script>
    const div1 = document.getElementsByTagName('div')[0];

    Element.prototype.insertAfter = function(newNode, refNode){
      const parent = refNode.parentNode;
      if(this.nextElementSibling == null) {
        refNode.appendChild(newNode);
      } else {
        parent.insertBefore(newNode, this.nextElementSibling);
      }
    }
    const newEle = document.createElement('p');

    div1.insertAfter(newEle, div1);
  </script>
</body>
</html>